<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>7-编译作用域-父子组件的作用域</title>
    <script src="js/vue.js"></script>
</head>

<body>
    <div id="app">
        <h1>我是父组件的html结构</h1>
        <custom>
            <h3 slot="msg">{{message}}</h3>
        </custom>
    </div>

    <script>
        Vue.component('custom', {
            template: `
                <div>        
                    <h2>自定义组件</h2>
                    <div>{{message}}</div>
                    <slot name="msg"><p>{{message}}</p></slot>          
                </div>                   
            `,
            data: function() {
                return {
                    message: '我是子组件的message'
                }
            }
        })

        new Vue({
            el: "#app",
            data: {
                message: '我是父组件的message'
            }
        })
    </script>
</body>

</html>